import { Model } from 'sutando';
import AdminMenus from './AdminMenus';
import dayjs from 'dayjs';

export default class AdminPermission extends Model {
  table = 'admin_permissions';       // 数据表名
  primaryKey = 'id';                 // 主键
  timestamps = true;                 // 自动维护 created_at 和 updated_at 字段

  serializeDate(date : Date) {
    return dayjs(date).format('YYYY-MM-DD HH:mm:ss');
  }

  relationMenus() {
    return this.belongsToMany(AdminMenus, 'admin_permission_menu', 'permission_id', 'menu_id');
  }
}
